﻿<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE html>
<html>
    <head>
    <meta charset="UTF-8">
    <title>添加配件</title>
	<script src="<%=basePath %>web/js/jquery.min.js"></script>
    <script src="<%=basePath %>web/js/jquery.easyui.min.js"></script>
    <script src="<%=basePath %>web/js/easyui-lang-zh_CN.js"></script>
    <link rel="stylesheet" href="<%=basePath %>web/themes/icon.css">
    <link rel="stylesheet" href="<%=basePath %>web/themes/default/easyui.css">
    <link rel="stylesheet" href="<%=basePath %>web/css/wu.css">
	<script>
        var  selectIndex = -1;
		var path=$("#path").val();  
        function hideTable(){
            $("#searchdiv").toggle();
        }
        $(function(){
        		Date.prototype.format = function(format)
				{
				 var o = {
				 "M+" : this.getMonth()+1, //month
				 "d+" : this.getDate(),    //day
				 "h+" : this.getHours(),   //hour
				 "m+" : this.getMinutes(), //minute
				 "s+" : this.getSeconds(), //second
				 "q+" : Math.floor((this.getMonth()+3)/3),  //quarter
				 "S" : this.getMilliseconds() //millisecond
				 }
				 if(/(y+)/.test(format)) format=format.replace(RegExp.$1,
				 (this.getFullYear()+"").substr(4 - RegExp.$1.length));
				 for(var k in o)if(new RegExp("("+ k +")").test(format))
				 format = format.replace(RegExp.$1,
				 RegExp.$1.length==1 ? o[k] :
				 ("00"+ o[k]).substr((""+ o[k]).length));
				 return format;
				}
        
        
        
        
        		var name=self.parent.$("#supplierName").val();
                $("#productList").datagrid({
                url:'/kxmanage/osb/findsell?findsupplierName='+name,
                pageNumber:1,
                pageSize:5,
                pageList:[5,10],
                pagination:true,
                checkOnSelect:true,
                columns:[[
                    {field:'ck',checkbox:true},
                    {field:'code',title:'销售单号',width:140},
                    {field:'orderTime',title:'订单日期',width:130,
                    formatter:function(value,row,index){
                            return (new Date(value)).format("yyyy-MM-dd hh:mm:ss");
                         }
                    },
                    {field:'customName',title:'客户名称',width:150},
                    {field:'amount',title:'数量',width:70},
                    {field:'money',title:'总货值(￥)',width:90},
                    {field:'amount',title:'未选数量',width:70},
                    {field:'money',title:'未选金额(￥)',width:90},
                    {field:'checkStatus',title:'审核状态',width:87,
                    	formatter:function(value,row,index){
                    	if(row.checkStatus==1){
                    		return "未审核";
                    	}else{
                    		return "已审核";
                    	}
                        }
                    
                    }
                ]],
                onClickRow:function(index,data){
                	$(this).datagrid('unselectRow',index);
                },
                toolbar:'#wu_toolbar'
            })
         $("#search_btn").click(function(){
	       var form=$("#form1");
  		 $("#productList").datagrid('load',serializeForm(form));
         })
         /* $.ajax({
         	type:"GET",//请求类型
		 	url:"/kxmanage/sellorderbill/findallpartname",//请求的url
		 	dataType:"json",//ajax接口（请求url）返回的数据类型
		 	success:function(data){//data：返回数据（json对象）
		 		if(data != null){
		 			$("#partTypeId").html("");
				var options = "<option value=\"0\">——请选择——</option>";
				for(var i = 0; i < data.length; i++){
					//alert(data[i].id);
					//alert(data[i].roleName);
					options += "<option value=\""+data[i].id+"\">"+data[i].typeName+"</option>";
				}
				$("#partTypeId").html(options);
				}
		 	}
         }) */
        
       });
        function addsellpart(){
          var row = $('#productList').datagrid('getSelections');
			if(row!=null&&row!=''){
			var data=JSON.stringify(row);
	          $.ajax({
        		url:"/kxmanage/osb/addsellpart",
        		data:{'data':data},
        		type:"post",
        		dataType:"json",
        		success:function(data){
        			parent.addsellpart(data,"sellpart");
        		}
        		});
			}else{
				alert("请选择配件");
			}
        }
        
        
      /*   function addpart(){
          var row = $('#productList').datagrid('getSelections');
			if(row!=null&&row!=''){
	          parent.addpart(row);
			}else{
				alert("请选择配件");
			}

        } */
        
        function closePart(){
          parent.closeSell();
        }
        
        
        //将表单序列化
		function serializeForm(form){
			var obj={};
			$.each(form.serializeArray(),function(index){
				  if(obj[this['name']]){
					obj[this['name']]=obj[this['name']]+','+this['value']
				 }else{
				   obj[this['name']]=this['value'];
				 }
			});
			return obj;
		}  
		function reload(){
        	$("#form1").form("reset");
        	$("#productList").datagrid('load',{});
        }
     </script>
  </head>
  
  <body>
    <div id="wu_toolbar">
    <input type="hidden" id="path" value="${pageContext.request.contextPath}"/>
    <div id="searchdiv" style="display: block;width: 100%;">
        <form name="form1" id="form1"> 
            <table width="100%" border="0" cellspacing="0" style="background-color:#c9dfff;" >
                <tbody><tr>
                    <td width="70"><b>检索条件:</b></td>
                    <td width="70" align="right">销售单号:</td>
                    <td width="150" align="left"><input name="findcode" class="easyui-textbox" type="text" id="findcode" value="" maxlength="100"></td>
                    <td width="70" align="right">开始日期:</td>
                    <td width="150" align="left"><div class="l-text-wrapper"><div class="l-text l-text-date"><input name="findstartDate" type="text" id="findstartDate" value="" maxlength="30" class="easyui-datebox" ligeruiid="findstartDate"><div class="l-text-l"></div><div class="l-text-r"></div><div class="l-trigger"><div class="l-trigger-icon"></div></div></div></div></td>
                    <td width="70" align="right">结束日期:</td>
                    <td width="150" align="left"><div class="l-text-wrapper"><div class="l-text l-text-date"><input name="findendDate" type="text" id="findendDate" value="" maxlength="30" class="easyui-datebox" ligeruiid="findendDate"><div class="l-text-l"></div><div class="l-text-r"></div><div class="l-trigger"><div class="l-trigger-icon"></div></div></div></div></td>
                    
                    <td width="72">
                        <a id="search_btn" href="javascript:;" class="easyui-linkbutton" data-options="iconCls:'icon-search'">搜索</a>
                    </td>
                    <td width="72">
                        <a id="reset_btn" href="#" onclick="reload()" class="easyui-linkbutton" data-options="iconCls:'icon-refresh'">重置</a>
                    </td>
                    <td width="0"></td>


                </tr>
                </tbody>
            </table>
            <input type="hidden" id="menuCode" value="100001001">
        </form>
    </div>
</div>
<div id="productList" class="easyui-datagrid">

</div>
<br/>

<div id="addButton" style="float:right">
  <a href="javascript:addsellpart()" class="easyui-linkbutton" style="margin-right: 10px">添加</a>
  <a href="javascript:closePart()" class="easyui-linkbutton">退出</a>
</div>
  </body>
</html>
